package com.naiterui.ehp.bs.cms.modules.agent.vo;

import com.naiterui.ehp.bs.cms.common.json.Dict;
import com.naiterui.ehp.bs.cms.modules.agent.entity.AgAgent;
import com.naiterui.ehp.bs.cms.modules.agent.util.FilePathUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;

import java.util.Date;

/**
 *
 * @author yiren
 * @since 2022/2/10
 */
@Data
@Builder
public class AgentDetailVO implements java.io.Serializable {
    @ApiModelProperty(value = "经纪人ID")
    private Long id;

    @ApiModelProperty(value = "姓名")
    private String name;

    @ApiModelProperty(value = "性别 0：未知；1：男；2：女")
    private Integer gender;

    @ApiModelProperty(value = "手机号")
    private String phone;

    @ApiModelProperty(value = "职称类型(1:大区经理，2:省区经理，3:经纪人)，描述请取titleTypeDescribe的值")
    @Dict(type="agent_title_type")
    private Integer titleType;

    @ApiModelProperty(value = "区域ID")
    private Long areaId;

    @ApiModelProperty(value = "区域名称")
    private String areaName;

    @ApiModelProperty(value = "身份证号")
    private String cardNo;

    @ApiModelProperty(value = "身份证正面照片")
    private String frontUrl;

    @ApiModelProperty(value = "身份证反面照片")
    private String backUrl;

    @ApiModelProperty(value = "用户状态，描述请取statusDescribe的值")
    @Dict(type="agent_status")
    private Integer status;

    @ApiModelProperty(value = "入职时间")
    private Date entryTime;

    public static AgentDetailVO of(AgAgent agent){
        return AgentDetailVO.builder().id(agent.getId())
                .name(agent.getName())
                .gender(agent.getGender())
                .phone(agent.getPhone())
                .cardNo(agent.getCardNo())
                .frontUrl(FilePathUtil.pathToUrl(agent.getFrontUrl()))
                .backUrl(FilePathUtil.pathToUrl(agent.getBackUrl()))
                .status(agent.getStatus())
                .entryTime(agent.getEntryTime())
                .build();
    }
}
